package com.imooc.api.controller.article;

import com.imooc.grace.result.GraceJSONResult;
import com.imooc.pojo.bo.NewArticleBO;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import java.util.Date;

/**
 * 文章业务
 */
@RequestMapping("article")
public interface ArticleControllerApi {

    /**
     * 用户发文
     */
    @PostMapping("createArticle")
    GraceJSONResult createArticle(@RequestBody @Valid NewArticleBO newArticleBO, BindingResult result);

    /**
     * 查询用户的所有文章列表
     */
    @PostMapping("queryMyList")
    GraceJSONResult queryMyList(@RequestParam String userId, @RequestParam String keyword, @RequestParam Integer status, @RequestParam Date startDate, @RequestParam Date endDate, @RequestParam Integer page, @RequestParam Integer pageSize);

    /**
     * 管理员查询用户的所有文章列表
     */
    @PostMapping("queryAllList")
    GraceJSONResult queryAllList(@RequestParam Integer status, @RequestParam Integer page, @RequestParam Integer pageSize);

    /**
     * 管理员对文章进行审核通过或者失败
     */
    @PostMapping("doReview")
    GraceJSONResult doReview(@RequestParam String articleId, @RequestParam Integer passOrNot);

    /**
     * 用户删除文章
     */
    @PostMapping("/delete")
    GraceJSONResult delete(@RequestParam String userId, @RequestParam String articleId);

    /**
     * 用户撤回文章
     */
    @PostMapping("/withdraw")
    GraceJSONResult withdraw(@RequestParam String userId, @RequestParam String articleId);

}
